package com.project.weimi.adapter;

import java.util.List;

import com.project.weimi.R;
import com.project.weimi.adapter.AllOrder_Adapter.ViewHolder;
import com.project.weimi.entity.response.OrderEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class InboundFragment_Adapter extends BaseAdapter {

	private Context context;
	private List<OrderEntity> list;

	public InboundFragment_Adapter(Context context, List<OrderEntity> list) {
		super();
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.inbound_item, null);
			holder = new ViewHolder();
			holder.inbound_title_item = (TextView) convertView.findViewById(R.id.inbound_title_item);
			holder.baby_shipped = (TextView) convertView.findViewById(R.id.baby_shipped);
			holder.inbound_color_item = (TextView) convertView.findViewById(R.id.inbound_color_item);
			holder.innboundprice_item = (TextView) convertView.findViewById(R.id.innboundprice_item);
			holder.inbound_list_item = (TextView) convertView.findViewById(R.id.inbound_list_item);
			holder._inbound_buy_num_item = (TextView) convertView.findViewById(R.id._inbound_buy_num_item);
			holder.inbound_sum_item = (TextView) convertView.findViewById(R.id.inbound_sum_item);
			holder.confirmation_of_receipt = (Button) convertView.findViewById(R.id.confirmation_of_receipt);
			holder.inbound_img_item = (ImageView) convertView.findViewById(R.id.inbound_img_item);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();

		}
		double sum_list = list.get(position).getBuy_num() * list.get(position).getPrice();
		double sum = ((double) (sum_list * 100.0)) / 100.0;
		holder.baby_shipped.setText(list.get(position).getTrading_status());
		holder.inbound_title_item.setText(list.get(position).getOrder_title());
		holder.inbound_color_item.setText("颜色分类：" + list.get(position).getOrder_color());
		holder.innboundprice_item.setText("¥" + list.get(position).getPrice() + "");
		holder.inbound_list_item.setText("¥" + list.get(position).getList() + "");
		holder._inbound_buy_num_item.setText("x" + list.get(position).getBuy_num() + "");
		holder.inbound_sum_item.setText("共" + list.get(position).getBuy_num() + "件商品  合计" + sum + "（含运费¥0.00）");
		holder.inbound_img_item.setImageResource(list.get(position).getImg());
		holder.confirmation_of_receipt.setText(list.get(position).getView_ogistics());
		return convertView;
	}

	class ViewHolder {
		ImageView inbound_img_item;
		TextView baby_shipped, inbound_title_item, inbound_color_item, innboundprice_item, inbound_list_item,
				_inbound_buy_num_item, inbound_sum_item;
		Button confirmation_of_receipt;
	}
}
